<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8" />
<title>cisau信院免费邮--校园邮箱第一品牌</title>
<link rel="shortcut icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon"/>
  
  <meta name="description" content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <link rel="stylesheet" href="<%=basePath %>js/jPlayer/jplayer.flat.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/bootstrap.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/animate.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/font-awesome.min.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/simple-line-icons.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/font.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/app.css" type="text/css" />  
</head>
<script type="text/javascript" src="<%=basePath %>js/jquery.min.js"></script>
<body class="">
	<!-- 隐藏域开始 -->
	<input type="hidden" name="owner" value="${USER.email }" id="owner">
	<!-- 隐藏域结束 -->
  <section class="vbox">

  	<jsp:include page="top.jsp"></jsp:include>


        <section id="ShowAll">
          <section class="hbox stretch">
            <section>
              <section class="vbox">
                <section class="scrollable padder-lg w-f-md" id="bjax-target">
                  <a href="" class="pull-right text-muted m-t-lg" data-toggle="class:fa-spin" ><i class="icon-refresh i-lg  inline"></i></a>
                  <h2 class="font-thin m-b">公告中心 <span class="musicbar animate inline m-l-sm" style="width:20px;height:20px">
                    <span class="bar1 a1 bg-primary lter"></span>
                    <span class="bar2 a2 bg-info lt"></span>
                    <span class="bar3 a3 bg-success"></span>
                    <span class="bar4 a4 bg-warning dk"></span>
                    <span class="bar5 a5 bg-danger dker"></span>
                  </span>
                  <div class="col-sm-10" style="font-size:10px;">
                        <label class="checkbox-inline">
                          <input type="radio" name="a" value="1"> 按级别排序
                        </label>
                        <label class="checkbox-inline">
                          <input type="radio" name="a" value="2"> 按时间排序
                        </label>
                        
                      </div>
                      </h2>
                  
                  <div class="row row-sm" id="informList">

			<!-- 通知展示页面开始 -->


 
                  </div>
                  
                  
                </section>


                
              </section>
            </section>



            <!-- 好友列表start -->
            <aside class="aside-md bg-light dk" id="sidebar" style="min-height:855px;">
              <section class="vbox animated fadeInRight">
                <section class="w-f-md scrollable hover" style="min-height:700px;">
                  <h4 class="font-thin m-l-md m-t">我的好友列表</h4>
                  <ul class="list-group no-bg no-borders auto m-t-n-xxs" id="myFriendList">



                  </ul>
                </section>
                <footer class="footer footer-md bg-black">
                  <form class="" role="search">
                    <div class="form-group clearfix m-b-none">
                      <div class="input-group m-t m-b">
                        <span class="input-group-btn">
                          <button type="submit" class="btn btn-sm bg-empty text-muted btn-icon"><i class="fa fa-search"></i></button>
                        </span>
                        <input type="text" oninput="likeFriend();" class="form-control input-sm text-white bg-empty b-b b-dark no-border" placeholder="Search friend" id="keyWord">
                      </div>
                    </div>
                  </form>
                </footer>
              </section>              
            </aside>

			<!-- 好友列表end -->

           
          </section>
          
        </section>
      </section>
    </section>    
  </section>


<script src="<%=basePath %>js/wizard/jquery.bootstrap.wizard.js"></script>
<script src="<%=basePath %>js/wizard/demo.js"></script>
  <script src="<%=basePath %>js/app.plugin.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/jquery.jplayer.min.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/add-on/jplayer.playlist.min.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/demo.js"></script>
  <input type="hidden" value="1" id="way">
</body>
<script>
$('input:radio:first').attr('checked', 'true');
$(function(){
	  $(":radio").click(function(){
		  var way = document.getElementById("way");
	   	way.value = $(this).val();
	   	showAll();
	  });
	 });
$(document).ready(function(){
	showAll();
	likeFriend();
});
	function addFriendList(n, item) {
		
		var val = "<a href=\""+
		"../email/toSendEmail?id="+item.id+
				"\">"+
			"<li class=\"list-group-item\">"+
			"<span class=\"pull-left thumb-xs m-t-xs avatar m-l-xs m-r-sm\" style=\"float: left;\">";
			if(""===item.picpath){
				val = val+"<i class=\"icon-users\" style=\"font-size:20px;\"></i>";
			}else{
				val = val+"<img src=\"../"+item.picpath+"\" alt=\"...\" class=\"img-circle\">";
			}
			
			val = val+"<i class=\"on b-light right sm\"></i>"+
			"</span>"+
			"<div class=\"clear\">"+
  			"<div><a>"+item.nickname+"</a></div>"+
 			 "<small class=\"text-muted\">"+item.friend+"</small>"+
			"</div>"+
			"</li> "+
			"</a>";
		

		$("#myFriendList").append(val);
	}
	
	function likeFriend(){
		debugger;
		var oval=document.getElementById("owner").value;
		var l = document.getElementById("myFriendList");
		var keyWord = document.getElementById("keyWord").value;
		
		l.innerHTML='';
		$.ajax( {
				url:'<%=basePath%>friend/findAllFriend',
				type : 'post',
				data : {
					myEmail : oval
				},
				datatype : "json",//"xml", "html", "script", "json", "jsonp", "text".           
				success : function(data) {
					var json = eval('(' + data + ')');
					$.each(json, function(n, item) {
						if(item.friend.indexOf(keyWord)>=0||item.nickname.indexOf(keyWord)>=0){
							addFriendList(n, item);
						}
						
					});
				},
				error : function() {
					alert("异常！！！");
					
				}
			});
	}
	function showAll(){
		debugger;
		var ways = document.getElementById("way").value;
		var l = document.getElementById("informList");
		l.innerHTML='';
		var everything = document.getElementById("everything").value;
		
		$.ajax( {
				url:'<%=basePath%>inform/findAllInform',
				type : 'post',
				data : {
					way:ways          
				},
				datatype : "json",//"xml", "html", "script", "json", "jsonp", "text".           
				success : function(data) {
					var json = eval('(' + data + ')');
					$.each(json, function(n, item) {
						if(item.title.indexOf(everything)>=0||item.explain.indexOf(everything)>=0||item.content.indexOf(everything)>=0){
							addInformList(n, item);
						}
					});
				},
				error : function() {
					alert("异常！！！");
					
				}
			});
	}
function addInformList(n, item){
	 var val = "<div class=\"col-xs-6 col-sm-4 col-md-3 col-lg-2\" style=\"margin-left:30px;\">"+
     "<div class=\"item\">"+
     "<div class=\"pos-rlt\">"+
       "<div class=\"bottom\">"+
         "<span class=\"badge bg-info m-l-sm m-b-sm\">"+item.createTime+"</span>"+
       "</div>"+
       "<div class=\"item-overlay opacity r r-2x bg-black\">"+
         "<div class=\"text-info padder m-t-sm text-sm\">";
         if(item.level==='1'){
        	 val =val+ "<i class=\"fa fa-star\"></i>"+
        	 "<i class=\"fa fa-star-o text-muted\"></i>"+
        	 "<i class=\"fa fa-star-o text-muted\"></i>";
         }else if(item.level==='2'){
        	 val =val+ "<i class=\"fa fa-star\"></i>"+
        	 "<i class=\"fa fa-star\"></i>"+
        	 "<i class=\"fa fa-star-o text-muted\"></i>";
         }else{
        	 val =val+ "<i class=\"fa fa-star\"></i>"+
        	 "<i class=\"fa fa-star\"></i>"+
        	 "<i class=\"fa fa-star\"></i>";
         }
         val = val + "</div>"+
         "<div class=\"center text-center m-t-n\">"+
           "<a href=\"../inform/findInformById?id="+item.id+"\">查看详情</a>"+
         "</div>"+
         "<div class=\"bottom padder m-b-sm\">";
         <!--如果是管理员用户则可以进行删除操作 -->
         if(${USER.flag == '2'}){
        	 val = val+ "<a href=\"javascript:delInformById('"+item.id+"');\" class=\"pull-right\">"+
             "<i class=\"icon-trash\"></i>"+
           "</a>";
         }
           
         val =val+"</div>"+
       "</div>";
       <!--如果文章带有图片，则显示图片 ， 若文章未添加图片则显示默认 -->
       if(item.picpath===""||item.picpath===null){
    	   val =val +"<a href=\"#\"><img src=\"../images/noP.jpg\" alt=\"\" class=\"r r-2x img-full\" style=\"width:250px;height:150px;\"></a>";
       }else{
    	   val =val +"<a href=\"#\"><img src=\"../"+item.picpath+"\" alt=\"\" class=\"r r-2x img-full\" style=\"width:250px;height:150px;\"></a>";
       }
       
     val = val +"</div>"+
     "<div class=\"padder-v\">"+
       "<a href=\"#\" class=\"text-ellipsis\">"+item.title+"</a>"+
       "<a href=\"#\" class=\"text-ellipsis text-xs text-muted\">"+item.explain+"</a>"+
     "</div>"+
   "</div>"+
 "</div>";
	 $("#informList").append(val);
 
}
      function delInformById(ele){
    	  $.ajax( {
				url:'<%=basePath%>inform/delInformById',
				type : 'post',
				data : {
					id : ele
				},
				datatype : "json",//"xml", "html", "script", "json", "jsonp", "text".           
				success : function(data) {
					showAll();
						
					
				},
				error : function() {
					alert("异常！！！");
					
				}
			});
      }
	
</script>
</html>